package me.a01immutable;

import java.util.Iterator;
import java.util.List;

public class ImmutableDemo1 {
    public static void main(String[] args) {
        //创建不可变的List集合
        List<String> list = List.of("zhangsan", "lisi", "wangwu");

        //只能查询
        for (String name : list) {
            System.out.println(name);
        }
        System.out.println("---------------------");

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            System.out.println(s);
        }
    }
}
